package com.unione.heathrobot

import android.graphics.PixelFormat
import android.os.Bundle
import android.view.MotionEvent
import android.view.View
import android.view.WindowManager
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.unione.healthrobot.R
import com.unione.unione_base.view.AppBaseActivity

class WelcomeActivity : AppBaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_welcome)
        loadImage(findViewById(R.id.iv_smile))
    }

    private fun loadImage(imageView: ImageView?) {
        val url = "file:///android_asset/smile.gif"
        Glide.with(this)
            .asGif()
            .load(url)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .into(imageView!!)
    }

    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
        when (ev?.action) {
            MotionEvent.ACTION_DOWN -> {
                finish()
            }

            MotionEvent.ACTION_UP -> {

            }
        }
        return super.dispatchTouchEvent(ev)
    }

//    fun hideAppBar() {
//        val decorView = window.decorView
//        val uiOptions = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
//                or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
//                or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//                or View.SYSTEM_UI_FLAG_IMMERSIVE)
//        decorView.systemUiVisibility = uiOptions
//        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
//        window.setFlags(
//            WindowManager.LayoutParams.FLAG_FULLSCREEN,
//            WindowManager.LayoutParams.FLAG_FULLSCREEN
//        )
//        window.setFormat(PixelFormat.TRANSLUCENT)
//        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
//    }

}